<?php
require_once('lib/post.php');
$is_admin = $_SESSION['status_code'] == 'ADMIN';

?>
<script src="pages_admin/redaction/_redaction.js" type="text/javascript"></script>
<h3>Gestion des news</h3>
<?php
$news = news_get_list();
if ($row = mysql_fetch_assoc($news)) {
	?>
	<table class="dataTable">
		<thead>
		<tr>
			<th>Titre</th>
			<th>Posté le</th>
			<th>Auteur</th>
			<?php echo $is_admin ? '<th>Action</th>' : ''; ?>
		</tr>
		</thead>
		<tbody>
	<?php
	do {
		echo '
		<tr>
			<td>'.$row['title'].'</td>
			<td>'.date_to_str($row['time_submit']).'</td>
			<td>'.$row['author_firstname'].' '.$row['author_name'].'</td>';

			if($is_admin)
				echo '
				<td>
					<a href="?p=redaction&amp;r=news_edit&amp;id='.$row['id'].'" title="Modifier cette news">
						<img src="images/icons/pencil.png" alt="edit" />
					</a>&nbsp;

					<span>
						<a href="javascript:void(0);" class="js-ask-validation" title="Supprimer cette news">
							<img src="images/icons/delete.png" alt="supprimer" />
						</a>
						<div class="hidden decalhaut">
							Supprimer définitivement ?<br />
							<a href="javascript:void(0);" class="js-del-post b-oui" id="post_'.$row['id'].'"></a>
							<a href="javascript:void(0);" class="js-hide b-non"></a>
						</div>
					</span>
				</td>';

			echo '
		</tr>';
	} while ($row = mysql_fetch_assoc($news));
	?>
		</tbody>
	</table>
<?php
}
else {
	?>
	<p class="info">
		Il n'y a aucune news pour le moment
	</p>
	<?php
}
